package com.example.Adapter;

import java.util.ArrayList;

import android.R;
import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

import com.example.object.Panel;

public class PanelAdapter implements SpinnerAdapter {
	Context context;
	public ArrayList<Panel> lstPanel = new ArrayList<Panel>();

	public PanelAdapter(Context context, ArrayList<Panel> lstPanel) {
		this.lstPanel = lstPanel;
		this.context = context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lstPanel.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return lstPanel.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return android.R.layout.simple_dropdown_item_1line;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View row = convertView;
		if (row == null) {
			row = LayoutInflater.from(context).inflate(
					R.layout.simple_spinner_item, null);

		}
		TextView tv = (TextView) row.findViewById(android.R.id.text1);
		tv.setText(lstPanel.get(position).getName());
		return row;
	}

	@Override
	public int getViewTypeCount() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean hasStableIds() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean isEmpty() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void registerDataSetObserver(DataSetObserver observer) {
		// TODO Auto-generated method stub

	}

	@Override
	public void unregisterDataSetObserver(DataSetObserver observer) {
		// TODO Auto-generated method stub

	}

	@Override
	public View getDropDownView(int position, View convertView, ViewGroup arg2) {
		// TODO Auto-generated method stub
		View row = convertView;
		if (row == null) {
			row = LayoutInflater.from(context).inflate(
					R.layout.simple_spinner_item, null);

		}
		TextView tv = (TextView) row.findViewById(android.R.id.text1);
		tv.setText(lstPanel.get(position).getName());
		return row;
	}

}
